package tech.xs.common.framework.domain.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;

import java.util.HashMap;
import java.util.Map;

public enum HttpContentTypeEnum implements BaseEnum {
    APPLICATION_JSON(1, "application/json");

    @EnumValue
    @JsonValue
    private final int value;
    @Getter
    private final String type;

    private static final Map<Integer, HttpContentTypeEnum> mappings = new HashMap<>(values().length);

    static {
        for (HttpContentTypeEnum item : values()) {
            mappings.put(item.getValue(), item);
        }
    }

    HttpContentTypeEnum(int value, String type) {
        this.value = value;
        this.type = type;
    }

    @JsonCreator(mode = JsonCreator.Mode.DELEGATING)
    public static HttpContentTypeEnum create(int value) {
        return mappings.get(value);
    }

    @Override
    public Integer getValue() {
        return value;
    }
}
